home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_03
/
kamradt
/
mempool.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-10
|
635b
|
37 lines
// listing 1.
#ifndef MEMPOOL_H
#define MEMPOOL_H
#include <stddef.h>
const CharSize = 8;
const PoolSize =
sizeof(unsigned long)*CharSize;
class MemoryPoolLink {
private:
friend class MemoryPool;
MemoryPoolLink(size_t _size,
MemoryPoolLink *_next);
~MemoryPoolLink();
void *malloc(size_t size);
void free(void *, size_t size);
unsigned long bits;
MemoryPoolLink *next;
char *data;
};
class MemoryPool {
MemoryPoolLink freeHead;
MemoryPoolLink usedHead;
size_t size;
public:
MemoryPool(size_t size);
void *add();
void *malloc();
void free(void *);
};
#endif